//
//  NSString+DateChange.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2020/3/16.
//  Copyright © 2020 mac. All rights reserved.
//

#import "NSString+DateChange.h"


@implementation NSString (DateChange)
//时间转转时间yyyy年
+(NSString *)stringDateTimeChangeStringDate_yyyy:(NSString *)stringTime
{
    //将传入时间转化成需要的格式
    NSDateFormatter *format=[[NSDateFormatter alloc]init];
    [format setDateFormat:@"yyyy年"];
    NSDate *fromdate=[format dateFromString:stringTime];
    
    NSDateFormatter *format1 = [[NSDateFormatter alloc] init];
    
    format1.dateFormat = @"yyyy";
    
    NSString *stringDate = [format1 stringFromDate:fromdate];
    
    return stringDate;
}


+(NSString *)stringDateTimeChangeStringDate_yyyy_MM:(NSString *)stringTime
{
    //将传入时间转化成需要的格式
    NSDateFormatter *format=[[NSDateFormatter alloc]init];
    [format setDateFormat:@"yyyy年MM月"];
    NSDate *fromdate=[format dateFromString:stringTime];
    
    NSDateFormatter *format1 = [[NSDateFormatter alloc] init];
    
    format1.dateFormat = @"yyyy-MM";
    
    NSString *stringDate = [format1 stringFromDate:fromdate];
    
    return stringDate;
}

+(NSString *)stringDateTimeChangeStringDate_yyyy_quater:(NSString *)stringTime
{
    //将传入时间转化成需要的格式
    NSDateFormatter *format=[[NSDateFormatter alloc]init];
    [format setDateFormat:@"yyyy年第M季"];
    NSDate *fromdate=[format dateFromString:stringTime];
    
    NSDateFormatter *format1 = [[NSDateFormatter alloc] init];
    
    format1.dateFormat = @"yyyy-M";
    
    NSString *stringDate = [format1 stringFromDate:fromdate];
    
    return stringDate;
}

//时间转转时间yyyy年MM月dd日
+(NSString *)stringDateTimeChangeStringDate_yyyy_MM_dd:(NSString *)stringTime
{
    //将传入时间转化成需要的格式
    NSDateFormatter *format=[[NSDateFormatter alloc]init];
    [format setDateFormat:@"yyyy年MM月dd日"];
    NSDate *fromdate=[format dateFromString:stringTime];
    
    NSDateFormatter *format1 = [[NSDateFormatter alloc] init];
    
    format1.dateFormat = @"yyyy-MM-dd";
    
    NSString *stringDate = [format1 stringFromDate:fromdate];
    
    return stringDate;
}


@end
